package com.anda.jsu.yangsp.core.view.util;

import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

import com.anda.jsu.yangsp.test.PageModelTest;


/**
 * 将Entity转换为CommonView对象
 * @author xiaolu
 * @since 2012-12-06
 *
 * @param <T>
 */
public class ConvertEntityToView {
	
	
	public static String getDeclaredType(Object obj){
		Method[] methods = obj.getClass().getDeclaredMethods();
		String typeName = "";
		for (Method method : methods) {
			if(!method.getName().equals("list")){
				continue;
			}
			Type[] paramTypeList = method.getGenericParameterTypes();
			for (Type paramType : paramTypeList) {
				if (paramType instanceof ParameterizedType) {
					Type[] types = ((ParameterizedType) paramType).getActualTypeArguments();
					for (Type type : types) {
						typeName = type.toString().replace("class ", "");
					}
				}
			}
		}
		return typeName;
	}
}
